// 抽离出jsx中不涉及dom元素的方法
import { updateApiRule } from '../service';


const handleUpdate = async (fields, vdiskName, currentPath) => {

    const hide = message.loading('正在添加');
    console.log("==+>> currentPath", currentPath)
    try {
        let _response = await updateApiRule({
            disk: vdiskName,
            location: `${currentPath}/${fields.value}`,
        })
        if (_response) {
            if (!_response.ok) {
                hide();
                return false;
            }
        }
        else {
            hide();
            message.success('添加成功');
            return true;
        }
    } catch (error) {
        hide();
        message.error('添加失败请重试！');
        return false;
    }
}


export { handleUpdate}